package testJdk.io.filewriter;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @ClassName : com.io.filewriter.TestCopy1
 * @Description : 类描述
 * Created by cyd on 2020-12-09 23:12:11
 */
public class TestCopy1 {
    public static void main(String[] args) throws IOException {
        //1.创建输入流和输出流

        try(FileReader fr = new FileReader("D:\\readme.txt");
            FileWriter fw = new FileWriter("D:\\readme2.txt")) {
            //2.使用流，复制文件
            //定义一个中转站 n
            int n = fr.read();
            while (-1 != n) {
                fw.write(n);
                n = fr.read();
                System.out.println(n + ":" + (char) n);
            }
        }

        //3.关闭流
        //fr.close();
        //fw.close();
    }
}
